package com.xm.xmapp.adapter;

import java.util.ArrayList;

import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;

import com.xm.xmapp.R;
import com.xm.xmapp.base.MyBaseAdapter;
import com.xm.xmapp.base.ViewHolder;
import com.xm.xmapp.response.bean.ResponseQuestionListBean;

public class QuestionListAdapter extends
		MyBaseAdapter<ResponseQuestionListBean> {

	private int seclect = -1;

	public QuestionListAdapter(ArrayList<ResponseQuestionListBean> list,
			Activity activity, int layoutId) {
		super(list, activity, layoutId);

	}

	@Override
	public void setValues(final ViewHolder holder,
			final ResponseQuestionListBean t, final int position) {

		holder.setText(R.id.title, t.question_title).setText(R.id.content,
				t.question_content);
		ImageView img = (ImageView) holder.getView(R.id.img);
		if (seclect == position) {
			holder.getView(R.id.view).setVisibility(View.VISIBLE);
			holder.getView(R.id.content).setVisibility(View.VISIBLE);

			img.setImageResource(R.mipmap.personal_back_icon2);
		} else {
			img.setImageResource(R.mipmap.personal_back_icon_1);
			holder.getView(R.id.view).setVisibility(View.GONE);
			holder.getView(R.id.content).setVisibility(View.GONE);
		}

		holder.getView(R.id.rel).setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {

				if (seclect == position)
					seclect = -1;
				else
					seclect = position;

				notifyDataSetChanged();

			}
		});
	}
}
